
//命令：dart run build_runner build
// 命令（自动检测）dart run build_runner watch


import 'package:dart_mappable/dart_mappable.dart';
part 'KeyValueBean.mapper.dart';
@MappableClass()
class KeyValueBean  with KeyValueBeanMappable  {
  // 数据字段
  String? name;
  String? values;
  String? key;
  String? value;
  String? abc;
  int? index;
  KeyValueBean? ui_select_bean;
  List<KeyValueBean>? _valueList;
  int? ui_select_view_data=0;

  // 嵌套字段（支持一层嵌套）
  KeyValueBean? worktype_id;
  KeyValueBean? worktype_ids;
  KeyValueBean? salary_type_id;
  KeyValueBean? year_salary_range_id;
  KeyValueBean? mont_salary_range_id;
  KeyValueBean? hour_salary_range_id;
  KeyValueBean? worktime_type_id;
  KeyValueBean? biz_type_id;
  KeyValueBean? nation_id;
  KeyValueBean? religion_id;
  KeyValueBean? gender_id;
  KeyValueBean? age_range_id;
  KeyValueBean? education_degree_id;
  KeyValueBean? work_age_range_id;
  KeyValueBean? employer_count_range_id;
  KeyValueBean? benefit_id;
  KeyValueBean? zodiac_id;
  KeyValueBean? constellation_id;
  KeyValueBean? source_type_id;
  KeyValueBean? marital_status_id;



  KeyValueBean.keyValue({ this.key, this.value,this.ui_select_view_data});
  KeyValueBean.keyValue2({ this.key, this.value,this.ui_select_view_data,this.name,this.abc});
  @MappableConstructor()
  KeyValueBean({
    this.abc,
    this.name,
    this.values,
    this.key,
    this.value,
    List<KeyValueBean>? valueList,
    this.worktype_id,
    this.worktype_ids,
    this.salary_type_id,
    this.year_salary_range_id,
    this.mont_salary_range_id,
    this.hour_salary_range_id,
    this.worktime_type_id,
    this.biz_type_id,
    this.nation_id,
    this.religion_id,
    this.gender_id,
    this.age_range_id,
    this.education_degree_id,
    this.work_age_range_id,
    this.employer_count_range_id,
    this.benefit_id,
    this.zodiac_id,
    this.constellation_id,
    this.source_type_id,
    this.marital_status_id,
  }){
    this._valueList=valueList;
  }

  static List<KeyValueBean> parseValueList(String valuesStr) {
    return valuesStr.split(',').map((item) {
      final parts = item.split('-');
      return KeyValueBean(
        key: parts[0],
        value: parts.sublist(1).join('-'), // 防止 value 中有 -
      );
    }).toList();
  }


  List<KeyValueBean> get valueList {
    if (this.values==null) {
        return [];
    }
    if (this._valueList==[]) {
      return [];
    }
    return _valueList ??= parseValueList(this.values ??= '');
  }


}
